package com.example.admindemo.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.admindemo.entity.SysUser;
import com.example.modeldemo.base.Result;
import org.springframework.web.bind.annotation.*;
import com.example.admindemo.service.SysUserService;

import javax.annotation.Resource;

/**
 * 用户表(SysUser)表控制层
 *
 * @author lc
 * @since 2022-01-11 15:53:27
 */
@RestController
@RequestMapping("sysUser")
public class SysUserController{
    /**
     * 服务对象
     */
    @Resource
    private SysUserService sysUserService;


    /**
     * 保存用户
     * @param sysUser
     * @return
     */
    @PostMapping("saveUser")
    public Result saveUser(@RequestBody SysUser sysUser){
        sysUserService.saveOrUpdate(sysUser);
        return Result.ok(sysUser);
    }

    /**
     * 查询分页用户列表
     * @param sysUser
     * @return
     */
    @PostMapping("pageUserList")
    public Result pageUserList(@RequestBody SysUser sysUser){
       return Result.ok(sysUserService.page(sysUser.getPage(),new LambdaQueryWrapper<>(sysUser)));
    }


}